package cn.db101.jcc.crawl.pipeline;

import cn.db101.jcc.entity.Lineup;
import cn.db101.jcc.service.LineupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

/**
 * @author zooy
 * @since 2024/6/11-12:43
 */
@Component
public class LineupPipeline implements Pipeline {

    @Autowired
    private LineupService lineupService;

    @Override
    public void process(ResultItems resultItems, Task task) {

        Lineup lineup = new Lineup();
        lineup.setTitle(resultItems.get("title"));
        lineup.setDescription(resultItems.get("description"));
        lineup.setContent(resultItems.get("content"));
        lineup.setImageUrl(resultItems.get("imageUrl"));
        lineupService.save(lineup);

    }
}
